package bdd.sql.server.bean;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Bean SiteServer.
 * @author Guillaume Pocas & Jean-Fraçois Augé
 */
@Entity
@Table(name = "serveur_site")
public class SiteServer {

	@Id
	@GeneratedValue
	@Column(name = "id")
	private int siteserv_id;
	
	@Column(name = "nom", unique = true, nullable = false, updatable = false)
	private String siteserv_name;
	
	@Column(name = "adresse_ip", unique = true, nullable = false, updatable = false)
	private String siteserv_ip;
	
	@Column(name = "nom_cluster", nullable = false)
	private String siteserv_cluster;
	
	@ManyToOne(cascade = {CascadeType.ALL})
    @JoinColumn(name = "id_serveurglobal")
	private GlobalServer serveur_global;
	
	@OneToMany(mappedBy="serveur_site")
    private Set<Camera> cameras;
	
	@ManyToOne(cascade = {CascadeType.ALL})
    @JoinColumn(name = "id_chiffrement")
	private Encryption chiffrement;
	
	@Column(name = "clef", unique = true, nullable = false)
	private String siteserv_key;
	
	// inutilisé
	//@ManyToOne
    //@JoinColumn(name = "qos_id")
	//@Deprecated
	//private QoS qos;
	
	/**
	 * Constructeur vide.
	 */
	public SiteServer() {}
 
	/**
	 * Constructeur.
	 * @param name nom du site
	 * @param ip adresse du site
	 */
	public SiteServer(String name, String ip, String cluster, String key) {
		this.siteserv_name = name;
		this.siteserv_ip = ip;
		this.siteserv_cluster = cluster;
		this.siteserv_key = key;
	}	
	
	public int getSiteserv_id() { return siteserv_id;	}
	public void setSiteserv_id(int siteserv_id) { this.siteserv_id = siteserv_id;	}

	public String getSiteserv_name() { return siteserv_name;	}
	public void setSiteserv_name(String siteserv_name) { this.siteserv_name = siteserv_name;	}

	public String getSiteserv_ip() { return siteserv_ip;	}
	public void setSiteserv_ip(String siteserv_ip) { this.siteserv_ip = siteserv_ip;	}

	public String getSiteserv_cluster() { return siteserv_cluster;	}
	public void setSiteserv_cluster(String siteserv_cluster) { this.siteserv_cluster = siteserv_cluster;	}

	public GlobalServer getGlobalServer() { return serveur_global;	}
	public void setGlobalServer(GlobalServer globalServer) { this.serveur_global = globalServer;	}

	public Set<Camera> getCameras() { return cameras;	}
	public void setCameras(Set<Camera> cameras) { this.cameras = cameras;	}

	public Encryption getEncryption() { return chiffrement;	}
	public void setEncryption(Encryption encryption) { this.chiffrement = encryption;	}

	public String getSiteserv_key() { return siteserv_key;	}
	public void setSiteserv_key(String siteserv_key) { this.siteserv_key = siteserv_key;	}

	//public QoS getQos() { return qos; 	}
	//public void setQos(QoS qos) { this.qos = qos;	}

	@Override
	public String toString(){ return this.siteserv_name; }

}
